home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / python / pythnlbn.lha / python-lib.info-2 < prev    next >
Encoding:
GNU Info File  |  1993-07-29  |  48.6 KB  |  1,256 lines

  1. This is Info file python-lib.info, produced by Makeinfo-1.43 from the
  2. input file @out.texi.
  3.  
  4. This file describes the built-in types, exceptions and functions and
  5. the standard modules that come with the Python system.  It assumes
  6. basic knowledge about the Python language.  For an informal
  7. introduction to the language, see the Python Tutorial.  The Python
  8. Reference Manual gives a more formal definition of the language. 
  9. (These manuals are not yet available in INFO or Texinfo format.)
  10.  
  11. Copyright (C) 1991, 1992, 1993 by Stichting Mathematisch Centrum,
  12. Amsterdam, The Netherlands.
  13.  
  14. All Rights Reserved
  15.  
  16. Permission to use, copy, modify, and distribute this software and its
  17. documentation for any purpose and without fee is hereby granted,
  18. provided that the above copyright notice appear in all copies and that
  19. both that copyright notice and this permission notice appear in
  20. supporting documentation, and that the names of Stichting Mathematisch
  21. Centrum or CWI not be used in advertising or publicity pertaining to
  22. distribution of the software without specific, written prior
  23. permission.
  24.  
  25. STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
  26. THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  27. FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
  28. FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  29. WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  30. ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  31. OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  32.  
  33. 
  34. File: python-lib.info,  Node: math,  Next: time,  Prev: __main__,  Up: Built-in Modules
  35.  
  36. Built-in Module `math'
  37. ======================
  38.  
  39. This module is always available.  It provides access to the
  40. mathematical functions defined by the C standard.  They are:
  41.  
  42.  -- function of module math: acos (X)
  43.  
  44.  -- function of module math: asin (X)
  45.  
  46.  -- function of module math: atan (X)
  47.  
  48.  -- function of module math: atan2 (X, Y)
  49.  
  50.  -- function of module math: ceil (X)
  51.  
  52.  -- function of module math: cos (X)
  53.  
  54.  -- function of module math: cosh (X)
  55.  
  56.  -- function of module math: exp (X)
  57.  
  58.  -- function of module math: fabs (X)
  59.  
  60.  -- function of module math: floor (X)
  61.  
  62.  -- function of module math: fmod (X, Y)
  63.  
  64.  -- function of module math: frexp (X)
  65.  
  66.  -- function of module math: ldexp (X, Y)
  67.  
  68.  -- function of module math: log (X)
  69.  
  70.  -- function of module math: log10 (X)
  71.  
  72.  -- function of module math: modf (X)
  73.  
  74.  -- function of module math: pow (X, Y)
  75.  
  76.  -- function of module math: sin (X)
  77.  
  78.  -- function of module math: sinh (X)
  79.  
  80.  -- function of module math: sqrt (X)
  81.  
  82.  -- function of module math: tan (X)
  83.  
  84.  -- function of module math: tanh (X)
  85.  
  86. Note that `frexp' and `modf' have a different call/return pattern than
  87. their C equivalents: they take a single argument and return a pair of
  88. values, rather than returning their second return value through an
  89. `output parameter' (there is no such thing in Python).
  90.  
  91. The module also defines two mathematical constants:
  92.  
  93.  -- data of module math: pi
  94.  
  95.  -- data of module math: e
  96.  
  97. 
  98. File: python-lib.info,  Node: time,  Next: regex,  Prev: math,  Up: Built-in Modules
  99.  
  100. Built-in Module `time'
  101. ======================
  102.  
  103. This module provides various time-related functions.  It is always
  104. available.  (On some systems, not all functions may exist; e.g. the
  105. "milli" variants can't always be implemented.)
  106.  
  107. An explanation of some terminology and conventions is in order.
  108.  
  109.    * The "epoch" is the point where the time starts.  On January 1st
  110.      that year, at 0 hours, the "time since the epoch" is zero.
  111.  
  112.    * UTC is Coordinated Universal Time (formerly known as Greenwich
  113.      Mean Time).  The acronym UTC is not a mistake but a compromise
  114.      between English and French.
  115.  
  116.    * DST is Daylight Saving Time, an adjustment of the timezone by
  117.      (usually) one hour during part of the year.  DST rules are magic
  118.      (determined by local law) and can change from year to year.  The C
  119.      library has a table containing the local rules (often it is read
  120.      from a system file for flexibility) and is the only source of
  121.      True Wisdom in this respect.
  122.  
  123.    * The precision of the various real-time functions may be less than
  124.      suggested by the units in which their value or argument is
  125.      expressed.  E.g. on most UNIX systems, the clock "ticks" only
  126.      every 1/50th or 1/100th of a second, and on the Mac, it ticks 60
  127.      times a second.
  128.  
  129. Functions and data items are:
  130.  
  131.  -- data of module time: altzone
  132.      The offset of the local DST timezone, in seconds west of the 0th
  133.      meridian, if one is defined.  Only use this if `daylight' is
  134.      nonzero.
  135.  
  136.  -- data of module time: daylight
  137.      Nonzero if a DST timezone is defined.
  138.  
  139.  -- function of module time: gmtime (SECS)
  140.      Convert a time expressed in seconds since the epoch to a tuple of
  141.      9 integers, in UTC: year (e.g. 1993), month (1-12), day (1-31),
  142.      hour (0-23), minute (0-59), second (0-59), weekday (0-6, monday
  143.      is 0), julian day (1-366), dst flag (always zero).  Fractions of
  144.      a second are ignored.  Note subtle differences with the C
  145.      function of this name.
  146.  
  147.  -- function of module time: localtime (SECS)
  148.      Like `gmtime' but converts to local time.  The dst flag is set to
  149.      1 when DST applies to the given time.
  150.  
  151.  -- function of module time: millisleep (MSECS)
  152.      Suspend execution for the given number of milliseconds. 
  153.      (Obsolete, you can now use use `sleep' with a floating point
  154.      argument.)
  155.  
  156.  -- function of module time: millitimer ()
  157.      Return the number of milliseconds of real time elapsed since some
  158.      point in the past that is fixed per execution of the python
  159.      interpreter (but may change in each following run).  The return
  160.      value may be negative, and it may wrap around.
  161.  
  162.  -- function of module time: mktime (TUPLE)
  163.      This is the inverse function of `localtime'.  Its argument is the
  164.      full 9-tuple (since the dst flag is needed).  It returns an
  165.      integer.
  166.  
  167.  -- function of module time: sleep (SECS)
  168.      Suspend execution for the given number of seconds.  The argument
  169.      may be a floating point number to indicate a more precise sleep
  170.      time.
  171.  
  172.  -- function of module time: time ()
  173.      Return the time as a floating point number expressed in seconds
  174.      since the epoch, in UTC.  Note that even though the time is
  175.      always returned as a floating point number, not all systems
  176.      provide time with a better precision than 1 second.  An
  177.      alternative for measuring precise intervals is `millitimer'.
  178.  
  179.  -- data of module time: timezone
  180.      The offset of the local (non-DST) timezone, in seconds west of
  181.      the 0th meridian (i.e. negative in most of Western Europe,
  182.      positive in the US, zero in the UK).
  183.  
  184.  -- data of module time: tzname
  185.      A tuple of two strings: the first is the name of the local non-DST
  186.      timezone, the second is the name of the local DST timezone.  If
  187.      no DST timezone is defined, the second string should not be used.
  188.  
  189. 
  190. File: python-lib.info,  Node: regex,  Next: marshal,  Prev: time,  Up: Built-in Modules
  191.  
  192. Built-in Module `regex'
  193. =======================
  194.  
  195. This module provides regular expression matching operations similar to
  196. those found in Emacs.  It is always available.
  197.  
  198. By default the patterns are Emacs-style regular expressions; there is
  199. a way to change the syntax to match that of several well-known UNIX
  200. utilities.
  201.  
  202. This module is 8-bit clean: both patterns and strings may contain null
  203. bytes and characters whose high bit is set.
  204.  
  205. *Please note:* There is a little-known fact about Python string
  206. literals which means that you don't usually have to worry about
  207. doubling backslashes, even though they are used to escape special
  208. characters in string literals as well as in regular expressions.  This
  209. is because Python doesn't remove backslashes from string literals if
  210. they are followed by an unrecognized escape character.  *However*, if
  211. you want to include a literal "backslash" in a regular expression
  212. represented as a string literal, you have to *quadruple* it.  E.g.  to
  213. extract LaTeX `\section{...}' headers from a document, you can use
  214. this pattern: `'\\\\section{\(.*\)}''.
  215.  
  216. The module defines these functions, and an exception:
  217.  
  218.  -- function of module regex: match (PATTERN, STRING)
  219.      Return how many characters at the beginning of STRING match the
  220.      regular expression PATTERN.  Return `-1' if the string does not
  221.      match the pattern (this is different from a zero-length match!).
  222.  
  223.  -- function of module regex: search (PATTERN, STRING)
  224.      Return the first position in STRING that matches the regular
  225.      expression PATTERN.  Return -1 if no position in the string
  226.      matches the pattern (this is different from a zero-length match
  227.      anywhere!).
  228.  
  229.  -- function of module regex: compile (PATTERN, TRANSLATE)
  230.      Compile a regular expression pattern into a regular expression
  231.      object, which can be used for matching using its `match' and
  232.      `search' methods, described below.  The optional TRANSLATE, if
  233.      present, must be a 256-character string indicating how characters
  234.      (both of the pattern and of the strings to be matched) are
  235.      translated before comparing them; the `i'-th element of the
  236.      string gives the translation for the character with ASCII code
  237.      `i'.
  238.  
  239.      The sequence
  240.  
  241.           prog = regex.compile(pat)
  242.           result = prog.match(str)
  243.      is equivalent to
  244.  
  245.           result = regex.match(pat, str)
  246.      but the version using `compile()' is more efficient when multiple
  247.      regular expressions are used concurrently in a single program. 
  248.      (The compiled version of the last pattern passed to
  249.      `regex.match()' or `regex.search()' is cached, so programs that
  250.      use only a single regular expression at a time needn't worry
  251.      about compiling regular expressions.)
  252.  
  253.  -- function of module regex: set_syntax (FLAGS)
  254.      Set the syntax to be used by future calls to `compile', `match'
  255.      and `search'.  (Already compiled expression objects are not
  256.      affected.)  The argument is an integer which is the OR of several
  257.      flag bits.  The return value is the previous value of the syntax
  258.      flags.  Names for the flags are defined in the standard module
  259.      `regex_syntax'; read the file `regex_syntax.py' for more
  260.      information.
  261.  
  262.  -- exception of module regex: error
  263.      Exception raised when a string passed to one of the functions here
  264.      is not a valid regular expression (e.g., unmatched parentheses) or
  265.      when some other error occurs during compilation or matching.  (It
  266.      is never an error if a string contains no match for a pattern.)
  267.  
  268.  -- data of module regex: casefold
  269.      A string suitable to pass as TRANSLATE argument to `compile' to
  270.      map all upper case characters to their lowercase equivalents.
  271.  
  272. Compiled regular expression objects support these methods:
  273.  
  274.  -- Method on regex: match (STRING, POS)
  275.      Return how many characters at the beginning of STRING match the
  276.      compiled regular expression.  Return `-1' if the string does not
  277.      match the pattern (this is different from a zero-length match!).
  278.  
  279.      The optional second parameter POS gives an index in the string
  280.      where the search is to start; it defaults to `0'.  This is not
  281.      completely equivalent to slicing the string; the `'^'' pattern
  282.      character matches at the real begin of the string and at positions
  283.      just after a newline, not necessarily at the index where the
  284.      search is to start.
  285.  
  286.  -- Method on regex: search (STRING, POS)
  287.      Return the first position in STRING that matches the regular
  288.      expression `pattern'.  Return `-1' if no position in the string
  289.      matches the pattern (this is different from a zero-length match
  290.      anywhere!).
  291.  
  292.      The optional second parameter has the same meaning as for the
  293.      `match' method.
  294.  
  295.  -- Method on regex: group (INDEX, INDEX, ...)
  296.      This method is only valid when the last call to the `match' or
  297.      `search' method found a match.  It returns one or more groups of
  298.      the match.  If there is a single INDEX argument, the result is a
  299.      single string; if there are multiple arguments, the result is a
  300.      tuple with one item per argument.  If the INDEX is zero, the
  301.      corresponding return value is the entire matching string; if it
  302.      is in the inclusive range [1..9], it is the string matching the
  303.      the corresponding parenthesized group (using the default syntax,
  304.      groups are parenthesized using `
  305.      (' and `
  306.      )').  If no such group exists, the corresponding result is `None'.
  307.  
  308. Compiled regular expressions support these data attributes:
  309.  
  310.  -- attribute of regex: regs
  311.      When the last call to the `match' or `search' method found a
  312.      match, this is a tuple of pairs of indices corresponding to the
  313.      beginning and end of all parenthesized groups in the pattern. 
  314.      Indices are relative to the string argument passed to `match' or
  315.      `search'.  The 0-th tuple gives the beginning and end or the
  316.      whole pattern.  When the last match or search failed, this is
  317.      `None'.
  318.  
  319.  -- attribute of regex: last
  320.      When the last call to the `match' or `search' method found a
  321.      match, this is the string argument passed to that method.  When
  322.      the last match or search failed, this is `None'.
  323.  
  324.  -- attribute of regex: translate
  325.      This is the value of the TRANSLATE argument to `regex.compile'
  326.      that created this regular expression object.  If the TRANSLATE
  327.      argument was omitted in the `regex.compile' call, this is `None'.
  328.  
  329. 
  330. File: python-lib.info,  Node: marshal,  Next: struct,  Prev: regex,  Up: Built-in Modules
  331.  
  332. Built-in Module `marshal'
  333. =========================
  334.  
  335. This module contains functions that can read and write Python values
  336. in a binary format.  The format is specific to Python, but independent
  337. of machine architecture issues (e.g., you can write a Python value to
  338. a file on a VAX, transport the file to a Mac, and read it back there).
  339.  Details of the format not explained here; read the source if you're
  340. interested.
  341.  
  342. Not all Python object types are supported; in general, only objects
  343. whose value is independent from a particular invocation of Python can
  344. be written and read by this module.  The following types are supported:
  345. `None', integers, long integers, floating point numbers, strings,
  346. tuples, lists, dictionaries, and code objects, where it should be
  347. understood that tuples, lists and dictionaries are only supported as
  348. long as the values contained therein are themselves supported; and
  349. recursive lists and dictionaries should not be written (they will
  350. cause an infinite loop).
  351.  
  352. There are functions that read/write files as well as functions
  353. operating on strings.
  354.  
  355. The module defines these functions:
  356.  
  357.  -- function of module marshal: dump (VALUE, FILE)
  358.      Write the value on the open file.  The value must be a supported
  359.      type.  The file must be an open file object such as `sys.stdout'
  360.      or returned by `open()' or `posix.popen()'.
  361.  
  362.      If the value has an unsupported type, garbage is written which
  363.      cannot be read back by `load()'.
  364.  
  365.  -- function of module marshal: load (FILE)
  366.      Read one value from the open file and return it.  If no valid
  367.      value is read, raise `EOFError', `ValueError' or `TypeError'. 
  368.      The file must be an open file object.
  369.  
  370.  -- function of module marshal: dumps (VALUE)
  371.      Return the string that would be written to a file by `dump(value,
  372.      file)'.  The value must be a supported type.
  373.  
  374.  -- function of module marshal: loads (STRING)
  375.      Convert the string to a value.  If no valid value is found, raise
  376.      `EOFError', `ValueError' or `TypeError'.  Extra characters in the
  377.      string are ignored.
  378.  
  379. 
  380. File: python-lib.info,  Node: struct,  Next: array,  Prev: marshal,  Up: Built-in Modules
  381.  
  382. Built-in module `struct'
  383. ========================
  384.  
  385. This module performs conversions between Python values and C structs
  386. represented as Python strings.  It uses "format strings" (explained
  387. below) as a compact descriptions of the lay-out of the C structs and
  388. the intended conversion to/from Python values.
  389.  
  390. The module defines the following exception and functions:
  391.  
  392.  -- exception of module struct: error
  393.      Exception raised on various occasions; argument is a string
  394.      describing what is wrong.
  395.  
  396.  -- function of module struct: pack (FMT, V1, V2, ...)
  397.      Return a string containing the values `V1, V2, ...' packed
  398.      according to the given format.  The arguments must match the
  399.      values required by the format exactly.
  400.  
  401.  -- function of module struct: unpack (FMT, STRING)
  402.      Unpack the string (presumably packed by `pack(FMT, ...)')
  403.      according to the given format.  The result is a tuple even if it
  404.      contains exactly one item.  The string must contain exactly the
  405.      amount of data required by the format (i.e.  `len(STRING)' must
  406.      equal `calcsize(FMT)').
  407.  
  408.  -- function of module struct: calcsize (FMT)
  409.      Return the size of the struct (and hence of the string)
  410.      corresponding to the given format.
  411.  
  412. Format characters have the following meaning; the conversion between C
  413. and Python values should be obvious given their types:
  414.  
  415. *Format*
  416.      *C*  --  *Python*
  417.  
  418. `x'
  419.      pad byte  --  no value
  420.  
  421. `c'
  422.      char  --  string of length 1
  423.  
  424. `b'
  425.      signed char  --  integer
  426.  
  427. `h'
  428.      short  --  integer
  429.  
  430. `i'
  431.      int  --  integer
  432.  
  433. `l'
  434.      long  --  integer
  435.  
  436. `f'
  437.      float  --  float
  438.  
  439. `d'
  440.      double  --  float
  441.  
  442. A format character may be preceded by an integral repeat count; e.g. 
  443. the format string `'4h'' means exactly the same as `'hhhh''.
  444.  
  445. C numbers are represented in the machine's native format and byte
  446. order, and properly aligned by skipping pad bytes if necessary
  447. (according to the rules used by the C compiler).
  448.  
  449. Examples (all on a big-endian machine):
  450.  
  451.      pack('hhl', 1, 2, 3) == '\000\001\000\002\000\000\000\003'
  452.      unpack('hhl', '\000\001\000\002\000\000\000\003') == (1, 2, 3)
  453.      calcsize('hhl') == 8
  454. Hint: to align the end of a structure to the alignment requirement of
  455. a particular type, end the format with the code for that type with a
  456. repeat count of zero, e.g. the format `'llh0l'' specifies two pad
  457. bytes at the end, assuming longs are aligned on 4-byte boundaries.
  458.  
  459. (More format characters are planned, e.g. `'s'' for character arrays,
  460. upper case for unsigned variants, and a way to specify the byte order,
  461. which is useful for [de]constructing network packets and
  462. reading/writing portable binary file formats like TIFF and AIFF.)
  463.  
  464. 
  465. File: python-lib.info,  Node: array,  Prev: struct,  Up: Built-in Modules
  466.  
  467. Built-in module `array'
  468. =======================
  469.  
  470. This module defines a new object type which can efficiently represent
  471. an array of basic values: characters, integers, floating point
  472. numbers.  Arrays are sequence types and behave very much like lists,
  473. except that the type of objects stored in them is constrained.  The
  474. type is specified at object creation time by using a "type code",
  475. which is a single character.  The following type codes are defined:
  476.  
  477. *Typecode*
  478.      *Type*  --  *Minimal size in bytes*
  479.  
  480. `'c''
  481.      character  --  1
  482.  
  483. `'b''
  484.      signed integer  --  1
  485.  
  486. `'h''
  487.      signed integer  --  2
  488.  
  489. `'l''
  490.      signed integer  --  4
  491.  
  492. `'f''
  493.      floating point  --  4
  494.  
  495. `'d''
  496.      floating point  --  8
  497.  
  498. The actual representation of values is determined by the machine
  499. architecture (strictly spoken, by the C implementation).
  500.  
  501. The module defines the following function:
  502.  
  503.  -- function of module array: array (TYPECODE, INITIALIZER)
  504.      Return a new array whose items are restricted by TYPECODE, and
  505.      initialized from the optional INITIALIZER value, which must be a
  506.      list or a string.  The list or string is passed to the new array's
  507.      `fromlist()' or `fromstring()' method (see below) to add initial
  508.      items to the array.
  509.  
  510. Array objects support the following data items and methods:
  511.  
  512.  -- data of module array: typecode
  513.      The typecode character used to create the array.
  514.  
  515.  -- data of module array: itemsize
  516.      The length in bytes of one array item in the internal
  517.      representation.
  518.  
  519.  -- function of module array: append (X)
  520.      Append a new item with value X to the end of the array.
  521.  
  522.  -- function of module array: insert (I, X)
  523.      Insert a new item with value X in the array before position I.
  524.  
  525.  -- function of module array: read (F, N)
  526.      Read N items (as machine values) from the file object F and
  527.      append them to the end of the array.  If less than N items are
  528.      available, `EOFError' is raised, but the items that were
  529.      available are still inserted into the array.
  530.  
  531.  -- function of module array: write (F)
  532.      Write all items (as machine values) to the file object F.
  533.  
  534.  -- function of module array: fromstring (S)
  535.      Appends items from the string, interpreting the string as an
  536.      array of machine values (i.e. as if it had been read from a file
  537.      using the `read()' method).
  538.  
  539.  -- function of module array: tostring ()
  540.      Convert the array to an array of machine values and return the
  541.      string representation (the same sequence of bytes that would be
  542.      written to a file by the `write()' method.)
  543.  
  544.  -- function of module array: fromlist (LIST)
  545.      Appends items from the list.  This is equivalent to `for x in
  546.      LIST: a.append(x)' except that if there is a type error, the
  547.      array is unchanged.
  548.  
  549.  -- function of module array: tolist ()
  550.      Convert the array to an ordinary list with the same items.
  551.  
  552. When an array object is printed or converted to a string, it is
  553. represented as `array(TYPECODE, INITIALIZER)'.  The INITIALIZER is
  554. omitted if the array is empty, otherwise it is a string if the
  555. TYPECODE is `'c'', otherwise it is a list of numbers.  The string is
  556. guaranteed to be able to be converted back to an array with the same
  557. type and value using reverse quotes (```').  Examples:
  558.  
  559.      array('l')
  560.      array('c', 'hello world')
  561.      array('l', [1, 2, 3, 4, 5])
  562.      array('d', [1.0, 2.0, 3.14])
  563.  
  564. 
  565. File: python-lib.info,  Node: Standard Modules,  Next: MOST OPERATING SYSTEMS,  Prev: Built-in Modules,  Up: Top
  566.  
  567. Standard Modules
  568. ****************
  569.  
  570. The following standard modules are defined.  They are available in one
  571. of the directories in the default module search path (try printing
  572. `sys.path' to find out the default search path.)
  573.  
  574. * Menu:
  575.  
  576. * string::                      Standard Module `string'
  577. * rand::                        Standard Module `rand'
  578. * whrandom::                    Standard Module `whrandom'
  579. * regsub::                      Standard Module `regsub'
  580. * os::                          Standard Module `os'
  581.  
  582. 
  583. File: python-lib.info,  Node: string,  Next: rand,  Up: Standard Modules
  584.  
  585. Standard Module `string'
  586. ========================
  587.  
  588. This module defines some constants useful for checking character
  589. classes, some exceptions, and some useful string functions.  The
  590. constants are:
  591.  
  592.  -- data of module string: digits
  593.      The string `'0123456789''.
  594.  
  595.  -- data of module string: hexdigits
  596.      The string `'0123456789abcdefABCDEF''.
  597.  
  598.  -- data of module string: letters
  599.      The concatenation of the strings `lowercase' and `uppercase'
  600.      described below.
  601.  
  602.  -- data of module string: lowercase
  603.      The string `'abcdefghijklmnopqrstuvwxyz''.
  604.  
  605.  -- data of module string: octdigits
  606.      The string `'01234567''.
  607.  
  608.  -- data of module string: uppercase
  609.      The string `'ABCDEFGHIJKLMNOPQRSTUVWXYZ''.
  610.  
  611.  -- data of module string: whitespace
  612.      A string containing all characters that are considered whitespace,
  613.      i.e., space, tab and newline.  This definition is used by
  614.      `split()' and `strip()'.
  615.  
  616. The exceptions are:
  617.  
  618.  -- exception of module string: atoi_error
  619.      Exception raised by `atoi' when a non-numeric string argument is
  620.      detected.  The exception argument is the offending string.
  621.  
  622.  -- exception of module string: index_error
  623.      Exception raised by `index' when SUB is not found.  The argument
  624.      are the offending arguments to index: `(S, SUB)'.
  625.  
  626. The functions are:
  627.  
  628.  -- function of module string: atoi (S)
  629.      Converts a string to a number.  The string must consist of one or
  630.      more digits, optionally preceded by a sign (`+' or `-').
  631.  
  632.  -- function of module string: expandtabs (S, TABSIZE)
  633.      Expand tabs in a string, i.e. replace them by one or more spaces,
  634.      depending on the current column and the given tab size.  The
  635.      column number is reset to zero after each newline occurring in
  636.      the string.  This doesn't understand other non-printing
  637.      characters or escape sequences.
  638.  
  639.  -- function of module string: find (S, SUB, I)
  640.      Return the lowest index in S not smaller than I where the
  641.      substring SUB is found.  Return `-1' when SUB does not occur as a
  642.      substring of S with index at least I.  If I is omitted, it
  643.      defaults to `0'.
  644.  
  645.  -- function of module string: index (S, SUB, I)
  646.      Like `index' but raise `index_error' when the substring is not
  647.      found.
  648.  
  649.  -- function of module string: lower (S)
  650.      Convert letters to lower case.
  651.  
  652.  -- function of module string: split (S)
  653.      Returns a list of the whitespace-delimited words of the string S.
  654.  
  655.  -- function of module string: splitfields (S, SEP)
  656.      Returns a list containing the fields of the string S, using the
  657.      string SEP as a separator.  The list will have one more items
  658.      than the number of non-overlapping occurrences of the separator
  659.      in the string.  Thus, `string.splitfields(S, ' ')' is not the
  660.      same as `string.split(S)', as the latter only returns non-empty
  661.      words.  As a special case, `splitfields(S, '')' returns `[S]',
  662.      for any string S.  (See also `regsub.split()'.)
  663.  
  664.  -- function of module string: join (WORDS)
  665.      Concatenate a list or tuple of words with intervening spaces.
  666.  
  667.  -- function of module string: joinfields (WORDS, SEP)
  668.      Concatenate a list or tuple of words with intervening separators. 
  669.      It is always true that `string.joinfields(string.splitfields(T,
  670.      SEP), SEP)' equals T.
  671.  
  672.  -- function of module string: strip (S)
  673.      Removes leading and trailing whitespace from the string S.
  674.  
  675.  -- function of module string: swapcase (S)
  676.      Converts lower case letters to upper case and vice versa.
  677.  
  678.  -- function of module string: upper (S)
  679.      Convert letters to upper case.
  680.  
  681.  -- function of module string: ljust (S, WIDTH)
  682.  
  683.  -- function of module string: rjust (S, WIDTH)
  684.  
  685.  -- function of module string: center (S, WIDTH)
  686.      These functions respectively left-justify, right-justify and
  687.      center a string in a field of given width.  They return a string
  688.      that is at least WIDTH characters wide, created by padding the
  689.      string S with spaces until the given width on the right, left or
  690.      both sides.  The string is never truncated.
  691.  
  692.  -- function of module string: zfill (S, WIDTH)
  693.      Pad a numeric string on the left with zero digits until the given
  694.      width is reached.  Strings starting with a sign are handled
  695.      correctly.
  696.  
  697. 
  698. File: python-lib.info,  Node: rand,  Next: whrandom,  Prev: string,  Up: Standard Modules
  699.  
  700. Standard Module `rand'
  701. ======================
  702.  
  703. This module implements a pseudo-random number generator with an
  704. interface similar to `rand()' in C.  It defines the following
  705. functions:
  706.  
  707.  -- function of module rand: rand ()
  708.      Returns an integer random number in the range [0 ... 32768).
  709.  
  710.  -- function of module rand: choice (S)
  711.      Returns a random element from the sequence (string, tuple or list)
  712.      S.
  713.  
  714.  -- function of module rand: srand (SEED)
  715.      Initializes the random number generator with the given integral
  716.      seed.  When the module is first imported, the random number is
  717.      initialized with the current time.
  718.  
  719. 
  720. File: python-lib.info,  Node: whrandom,  Next: regsub,  Prev: rand,  Up: Standard Modules
  721.  
  722. Standard Module `whrandom'
  723. ==========================
  724.  
  725. This module implements a Wichmann-Hill pseudo-random number generator. 
  726. It defines the following functions:
  727.  
  728.  -- function of module whrandom: random ()
  729.      Returns the next random floating point number in the range [0.0
  730.      ... 1.0).
  731.  
  732.  -- function of module whrandom: seed (X, Y, Z)
  733.      Initializes the random number generator from the integers X, Y and
  734.      Z.  When the module is first imported, the random number is
  735.      initialized using values derived from the current time.
  736.  
  737. 
  738. File: python-lib.info,  Node: regsub,  Next: os,  Prev: whrandom,  Up: Standard Modules
  739.  
  740. Standard Module `regsub'
  741. ========================
  742.  
  743. This module defines a number of functions useful for working with
  744. regular expressions (see built-in module `regex').
  745.  
  746.  -- function of module regsub: sub (PAT, REPL, STR)
  747.      Replace the first occurrence of pattern PAT in string STR by
  748.      replacement REPL.  If the pattern isn't found, the string is
  749.      returned unchanged.  The pattern may be a string or an already
  750.      compiled pattern.  The replacement may contain references
  751.      `\DIGIT' to subpatterns and escaped backslashes.
  752.  
  753.  -- function of module regsub: gsub (PAT, REPL, STR)
  754.      Replace all (non-overlapping) occurrences of pattern PAT in
  755.      string STR by replacement REPL.  The same rules as for `sub()'
  756.      apply.  Empty matches for the pattern are replaced only when not
  757.      adjacent to a previous match, so e.g.  `gsub('', '-', 'abc')'
  758.      returns `'-a-b-c-''.
  759.  
  760.  -- function of module regsub: split (STR, PAT)
  761.      Split the string STR in fields separated by delimiters matching
  762.      the pattern PAT, and return a list containing the fields.  Only
  763.      non-empty matches for the pattern are considered, so e.g. 
  764.      `split('a:b', ':*')' returns `['a', 'b']' and `split('abc', '')'
  765.      returns `['abc']'.
  766.  
  767. 
  768. File: python-lib.info,  Node: os,  Prev: regsub,  Up: Standard Modules
  769.  
  770. Standard Module `os'
  771. ====================
  772.  
  773. This module provides a more portable way of using operating system
  774. (OS) dependent functionality than importing an OS dependent built-in
  775. module like `posix'.
  776.  
  777. When the optional built-in module `posix' is available, this module
  778. exports the same functions and data as `posix'; otherwise, it searches
  779. for an OS dependent built-in module like `mac' and exports the same
  780. functions and data as found there.  The design of all Python's
  781. built-in OS dependen modules is such that as long as the same
  782. functionality is available, it uses the same interface; e.g., the
  783. function `os.stat(FILE)' returns stat info about a FILE in a format
  784. compatible with the POSIX interface.
  785.  
  786. Extensions peculiar to a particular OS are also available through the
  787. `os' module, but using them is of course a threat to portability!
  788.  
  789. Note that after the first time `os' is imported, there is *no*
  790. performance penalty in using functions from `os' instead of directly
  791. from the OS dependent built-in module, so there should be *no* reason
  792. not to use `os'!
  793.  
  794. In addition to whatever the correct OS dependent module exports, the
  795. following variables are always exported by `os':
  796.  
  797.  -- data of module os: name
  798.      The name of the OS dependent module imported, e.g. `'posix'' or
  799.      `'mac''.
  800.  
  801.  -- data of module os: path
  802.      The corresponding OS dependent standard module for pathname
  803.      operations, e.g., `posixpath' or `macpath'.  Thus, (given the
  804.      proper imports), `os.path.split(FILE)' is equivalent to but more
  805.      portable than `posixpath.split(FILE)'.
  806.  
  807.  -- data of module os: curdir
  808.      The constant string used by the OS to refer to the current
  809.      directory, e.g. `'.'' for POSIX or `':'' for the Mac.
  810.  
  811.  -- data of module os: pardir
  812.      The constant string used by the OS to refer to the parent
  813.      directory, e.g. `'..'' for POSIX or `'::'' for the Mac.
  814.  
  815.  -- data of module os: sep
  816.      The character used by the OS to separate pathname components, e.g. 
  817.      `'/'' for POSIX or `':'' for the Mac.  Note that knowing this is
  818.      not sufficient to be able to parse or concatenate
  819.      pathnames--better use `os.path.split()' and `os.path.join()'--but
  820.      it is occasionally useful.
  821.  
  822. 
  823. File: python-lib.info,  Node: MOST OPERATING SYSTEMS,  Next: UNIX ONLY,  Prev: Standard Modules,  Up: Top
  824.  
  825. MOST OPERATING SYSTEMS
  826. **********************
  827.  
  828. * Menu:
  829.  
  830. * posix::                       Built-in Module `posix'
  831. * posixpath::                   Standard Module `posixpath'
  832. * getopt::                      Standard Module `getopt'
  833.  
  834. 
  835. File: python-lib.info,  Node: posix,  Next: posixpath,  Up: MOST OPERATING SYSTEMS
  836.  
  837. Built-in Module `posix'
  838. =======================
  839.  
  840. This module provides access to operating system functionality that is
  841. standardized by the C Standard and the POSIX standard (a thinly
  842. diguised UNIX interface).  It is available in all Python versions
  843. except on the Macintosh; the MS-DOS version does not support certain
  844. functions.  The descriptions below are very terse; refer to the
  845. corresponding UNIX manual entry for more information.
  846.  
  847. Errors are reported as exceptions; the usual exceptions are given for
  848. type errors, while errors reported by the system calls raise
  849. `posix.error', described below.
  850.  
  851. Module `posix' defines the following data items:
  852.  
  853.  -- data of module posix: environ
  854.      A dictionary representing the string environment at the time the
  855.      interpreter was started.  (Modifying this dictionary does not
  856.      affect the string environment of the interpreter.) For example,
  857.      `posix.environ['HOME']' is the pathname of your home directory,
  858.      equivalent to `getenv("HOME")' in C.
  859.  
  860.  -- exception of module posix: error
  861.      This exception is raised when an POSIX function returns a
  862.      POSIX-related error (e.g., not for illegal argument types).  Its
  863.      string value is `'posix.error''.  The accompanying value is a
  864.      pair containing the numeric error code from `errno' and the
  865.      corresponding string, as would be printed by the C function
  866.      `perror()'.
  867.  
  868. It defines the following functions:
  869.  
  870.  -- function of module posix: chdir (PATH)
  871.      Change the current working directory to PATH.
  872.  
  873.  -- function of module posix: chmod (PATH, MODE)
  874.      Change the mode of PATH to the numeric MODE.
  875.  
  876.  -- function of module posix: close (FD)
  877.      Close file descriptor FD.
  878.  
  879.  -- function of module posix: dup (FD)
  880.      Return a duplicate of file descriptor FD.
  881.  
  882.  -- function of module posix: dup2 (FD, FD2)
  883.      Duplicate file descriptor FD to FD2, closing the latter first if
  884.      necessary.  Return `None'.
  885.  
  886.  -- function of module posix: _exit (N)
  887.      Exit to the system with status N, without calling cleanup
  888.      handlers, flushing stdio buffers, etc.  (Not on MS-DOS.)
  889.  
  890.      Note: the standard way to exit is `sys.exit(N)'.  `posix.exit()'
  891.      should normally only be used in the child process after a
  892.      `fork()'.
  893.  
  894.  -- function of module posix: exec (PATH, ARGS)
  895.      Execute the executable PATH with argument list ARGS, replacing
  896.      the current process (i.e., the Python interpreter).  The argument
  897.      list may be a tuple or list of strings.  (Not on MS-DOS.)
  898.  
  899.  -- function of module posix: fork ()
  900.      Fork a child process.  Return 0 in the child, the child's process
  901.      id in the parent.  (Not on MS-DOS.)
  902.  
  903.  -- function of module posix: fstat (FD)
  904.      Return status for file descriptor FD, like `stat()'.
  905.  
  906.  -- function of module posix: getcwd ()
  907.      Return a string representing the current working directory.
  908.  
  909.  -- function of module posix: getegid ()
  910.      Return the current process's effective group id.  (Not on MS-DOS.)
  911.  
  912.  -- function of module posix: geteuid ()
  913.      Return the current process's effective user id.  (Not on MS-DOS.)
  914.  
  915.  -- function of module posix: getgid ()
  916.      Return the current process's group id.  (Not on MS-DOS.)
  917.  
  918.  -- function of module posix: getpid ()
  919.      Return the current process id.  (Not on MS-DOS.)
  920.  
  921.  -- function of module posix: getppid ()
  922.      Return the parent's process id.  (Not on MS-DOS.)
  923.  
  924.  -- function of module posix: getuid ()
  925.      Return the current process's user id.  (Not on MS-DOS.)
  926.  
  927.  -- function of module posix: kill (PID, SIG)
  928.      Kill the process PID with signal SIG.  (Not on MS-DOS.)
  929.  
  930.  -- function of module posix: link (SRC, DST)
  931.      Create a hard link pointing to SRC named DST.  (Not on MS-DOS.)
  932.  
  933.  -- function of module posix: listdir (PATH)
  934.      Return a list containing the names of the entries in the
  935.      directory.  The list is in arbitrary order.  It includes the
  936.      special entries `'.'' and `'..'' if they are present in the
  937.      directory.
  938.  
  939.  -- function of module posix: lseek (FD, POS, HOW)
  940.      Set the current position of file descriptor FD to position POS,
  941.      modified by HOW: 0 to set the position relative to the beginning
  942.      of the file; 1 to set it relative to the current position; 2 to
  943.      set it relative to the end of the file.
  944.  
  945.  -- function of module posix: lstat (PATH)
  946.      Like `stat()', but do not follow symbolic links.  (On systems
  947.      without symbolic links, this is identical to `posix.stat'.)
  948.  
  949.  -- function of module posix: mkdir (PATH, MODE)
  950.      Create a directory named PATH with numeric mode MODE.
  951.  
  952.  -- function of module posix: nice (INCREMENT)
  953.      Add INCR to the process' "niceness".  Return the new niceness. 
  954.      (Not on MS-DOS.)
  955.  
  956.  -- function of module posix: open (FILE, FLAGS, MODE)
  957.      Open the file FILE and set various flags according to FLAGS and
  958.      possibly its mode according to MODE.  Return the file descriptor
  959.      for the newly opened file.
  960.  
  961.  -- function of module posix: pipe ()
  962.      Create a pipe.  Return a pair of file descriptors `(r, w)' usable
  963.      for reading and writing, respectively.  (Not on MS-DOS.)
  964.  
  965.  -- function of module posix: popen (COMMAND, MODE)
  966.      Open a pipe to or from COMMAND.  The return value is an open file
  967.      object connected to the pipe, which can be read or written
  968.      depending on whether MODE is `'r'' or `'w''.  (Not on MS-DOS.)
  969.  
  970.  -- function of module posix: read (FD, N)
  971.      Read at most N bytes from file descriptor FD.  Return a string
  972.      containing the bytes read.
  973.  
  974.  -- function of module posix: readlink (PATH)
  975.      Return a string representing the path to which the symbolic link
  976.      points.  (On systems without symbolic links, this always raises
  977.      `posix.error'.)
  978.  
  979.  -- function of module posix: rename (SRC, DST)
  980.      Rename the file or directory SRC to DST.
  981.  
  982.  -- function of module posix: rmdir (PATH)
  983.      Remove the directory PATH.
  984.  
  985.  -- function of module posix: stat (PATH)
  986.      Perform a *stat* system call on the given path.  The return value
  987.      is a tuple of at least 10 integers giving the most important (and
  988.      portable) members of the *stat* structure, in the order `st_mode',
  989.      `st_ino', `st_dev', `st_nlink', `st_uid', `st_gid', `st_size',
  990.      `st_atime', `st_mtime', `st_ctime'.  More items may be added at
  991.      the end by some implementations.  (On MS-DOS, some items are
  992.      filled with dummy values.)
  993.  
  994.      Note: The standard module `stat' defines functions and constants
  995.      that are useful for extracting information from a stat structure.
  996.  
  997.  -- function of module posix: symlink (SRC, DST)
  998.      Create a symbolic link pointing to SRC named DST.  (On systems
  999.      without symbolic links, this always raises `posix.error'.)
  1000.  
  1001.  -- function of module posix: system (COMMAND)
  1002.      Execute the command (a string) in a subshell.  This is
  1003.      implemented by calling the Standard C function `system()', and
  1004.      has the same limitations.  Changes to `posix.environ',
  1005.      `sys.stdin' etc. are not reflected in the environment of the
  1006.      executed command.  The return value is the exit status of the
  1007.      process as returned by Standard C `system()'.
  1008.  
  1009.  -- function of module posix: times ()
  1010.      Return a 4-tuple of floating point numbers indicating accumulated
  1011.      CPU times, in seconds.  The items are: user time, system time,
  1012.      children's user time, and children's system time, in that order. 
  1013.      See the UNIX manual page times(2).  (Not on MS-DOS.)
  1014.  
  1015.  -- function of module posix: umask (MASK)
  1016.      Set the current numeric umask and returns the previous umask. 
  1017.      (Not on MS-DOS.)
  1018.  
  1019.  -- function of module posix: uname ()
  1020.      Return a 5-tuple containing information identifying the current
  1021.      operating system.  The tuple contains 5 strings: `(SYSNAME,
  1022.      NODENAME, RELEASE, VERSION, MACHINE)'.  Some systems truncate the
  1023.      nodename to 8 characters or to the leading component; an better
  1024.      way to get the hostname is `socket.gethostname()'.  (Not on
  1025.      MS-DOS, nor on older UNIX systems.)
  1026.  
  1027.  -- function of module posix: unlink (PATH)
  1028.      Unlink PATH.
  1029.  
  1030.  -- function of module posix: utime (PATH, (ATIME, MTIME))
  1031.      Set the access and modified time of the file to the given values. 
  1032.      (The second argument is a tuple of two items.)
  1033.  
  1034.  -- function of module posix: wait ()
  1035.      Wait for completion of a child process, and return a tuple
  1036.      containing its pid and exit status indication (encoded as by
  1037.      UNIX).  (Not on MS-DOS.)
  1038.  
  1039.  -- function of module posix: waitpid (PID, OPTIONS)
  1040.      Wait for completion of a child process given by proces id, and
  1041.      return a tuple containing its pid and exit status indication
  1042.      (encoded as by UNIX).  The semantics of the call are affected by
  1043.      the value of the integer options, which should be 0 for normal
  1044.      operation.  (If the system does not support waitpid(), this
  1045.      always raises `posix.error'.  Not on MS-DOS.)
  1046.  
  1047.  -- function of module posix: write (FD, STR)
  1048.      Write the string STR to file descriptor fd.  Return the number of
  1049.      bytes actually written.
  1050.  
  1051. 
  1052. File: python-lib.info,  Node: posixpath,  Next: getopt,  Prev: posix,  Up: MOST OPERATING SYSTEMS
  1053.  
  1054. Standard Module `posixpath'
  1055. ===========================
  1056.  
  1057. This module implements some useful functions on POSIX pathnames.
  1058.  
  1059.  -- function of module posixpath: basename (P)
  1060.      Return the base name of pathname P.  This is the second half of
  1061.      the pair returned by `posixpath.split(P)'.
  1062.  
  1063.  -- function of module posixpath: commonprefix (LIST)
  1064.      Return the longest string that is a prefix of all strings in LIST. 
  1065.      If LIST is empty, return the empty string (`''').
  1066.  
  1067.  -- function of module posixpath: exists (P)
  1068.      Return true if P refers to an existing path.
  1069.  
  1070.  -- function of module posixpath: expanduser (P)
  1071.      Return the argument with an initial component of `~' or `~USER'
  1072.      replaced by that USER's home directory.  An initial `~' is
  1073.      replaced by the environment variable `$HOME'; an initial `~USER'
  1074.      is looked up in the password directory through the built-in
  1075.      module `pwd'.  If the expansion fails, or if the path does not
  1076.      begin with a tilde, the path is returned unchanged.
  1077.  
  1078.  -- function of module posixpath: isabs (P)
  1079.      Return true if P is an absolute pathname (begins with a slash).
  1080.  
  1081.  -- function of module posixpath: isfile (P)
  1082.      Return true if P is an existing regular file.  This follows
  1083.      symbolic links, so both islink() and isfile() can be true for the
  1084.      same path.
  1085.  
  1086.  -- function of module posixpath: isdir (P)
  1087.      Return true if P is an existing directory.  This follows symbolic
  1088.      links, so both islink() and isdir() can be true for the same path.
  1089.  
  1090.  -- function of module posixpath: islink (P)
  1091.      Return true if P refers to a directory entry that is a symbolic
  1092.      link.  Always false if symbolic links are not supported.
  1093.  
  1094.  -- function of module posixpath: ismount (P)
  1095.      Return true if P is a mount point.  (This currently checks whether
  1096.      `P/..' is on a different device as P or whether `P/..' and P
  1097.      point to the same i-node on the same device -- is this test
  1098.      correct for all UNIX and POSIX variants?)
  1099.  
  1100.  -- function of module posixpath: join (P, Q)
  1101.      Join the paths P and Q intelligently: If Q is an absolute path,
  1102.      the return value is Q.  Otherwise, the concatenation of P and Q
  1103.      is returned, with a slash (`'/'') inserted unless P is empty or
  1104.      ends in a slash.
  1105.  
  1106.  -- function of module posixpath: normcase (P)
  1107.      Normalize the case of a pathname.  This returns the path
  1108.      unchanged; however, a similar function in `macpath' converts
  1109.      upper case to lower case.
  1110.  
  1111.  -- function of module posixpath: samefile (P, Q)
  1112.      Return true if both pathname arguments refer to the same file or
  1113.      directory (as indicated by device number and i-node number). 
  1114.      Raise an exception if a stat call on either pathname fails.
  1115.  
  1116.  -- function of module posixpath: split (P)
  1117.      Split the pathname P in a pair `(HEAD, TAIL)', where TAIL is the
  1118.      last pathname component and HEAD is everything leading up to
  1119.      that.  If P ends in a slash (except if it is the root), the
  1120.      trailing slash is removed and the operation applied to the
  1121.      result; otherwise, `join(HEAD, TAIL)' equals P.  The TAIL part
  1122.      never contains a slash.  Some boundary cases: if P is the root,
  1123.      HEAD equals P and TAIL is empty; if P is empty, both HEAD and
  1124.      TAIL are empty; if P contains no slash, HEAD is empty and TAIL
  1125.      equals P.
  1126.  
  1127.  -- function of module posixpath: splitext (P)
  1128.      Split the pathname P in a pair `(ROOT, EXT)' such that `ROOT +
  1129.      EXT == P', the last component of ROOT contains no periods, and
  1130.      EXT is empty or begins with a period.
  1131.  
  1132.  -- function of module posixpath: walk (P, VISIT, ARG)
  1133.      Calls the function VISIT with arguments `(ARG, DIRNAME, NAMES)'
  1134.      for each directory in the directory tree rooted at P (including P
  1135.      itself, if it is a directory).  The argument DIRNAME specifies
  1136.      the visited directory, the argument NAMES lists the files in the
  1137.      directory (gotten from `posix.listdir(DIRNAME)').  The VISIT
  1138.      function may modify NAMES to influence the set of directories
  1139.      visited below DIRNAME, e.g., to avoid visiting certain parts of
  1140.      the tree.  (The object referred to by NAMES must be modified in
  1141.      place, using `del' or slice assignment.)
  1142.  
  1143. 
  1144. File: python-lib.info,  Node: getopt,  Prev: posixpath,  Up: MOST OPERATING SYSTEMS
  1145.  
  1146. Standard Module `getopt'
  1147. ========================
  1148.  
  1149. This module helps scripts to parse the command line arguments in
  1150. `sys.argv'.  It uses the same conventions as the UNIX `getopt()'
  1151. function.  It defines the function `getopt.getopt(args, options)' and
  1152. the exception `getopt.error'.
  1153.  
  1154. The first argument to `getopt()' is the argument list passed to the
  1155. script with its first element chopped off (i.e., `sys.argv[1:]').  The
  1156. second argument is the string of option letters that the script wants
  1157. to recognize, with options that require an argument followed by a
  1158. colon (i.e., the same format that UNIX `getopt()' uses).  The return
  1159. value consists of two elements: the first is a list of
  1160. option-and-value pairs; the second is the list of program arguments
  1161. left after the option list was stripped (this is a trailing slice of
  1162. the first argument).  Each option-and-value pair returned has the
  1163. option as its first element, prefixed with a hyphen (e.g., `'-x''),
  1164. and the option argument as its second element, or an empty string if
  1165. the option has no argument.  The options occur in the list in the same
  1166. order in which they were found, thus allowing multiple occurrences. 
  1167. Example:
  1168.  
  1169.      >>> import getopt, string
  1170.      >>> args = string.split('-a -b -cfoo -d bar a1 a2')
  1171.      >>> args
  1172.      ['-a', '-b', '-cfoo', '-d', 'bar', 'a1', 'a2']
  1173.      >>> optlist, args = getopt.getopt(args, 'abc:d:')
  1174.      >>> optlist
  1175.      [('-a', ''), ('-b', ''), ('-c', 'foo'), ('-d', 'bar')]
  1176.      >>> args
  1177.      ['a1', 'a2']
  1178.      >>>
  1179. The exception `getopt.error = 'getopt error'' is raised when an
  1180. unrecognized option is found in the argument list or when an option
  1181. requiring an argument is given none.  The argument to the exception is
  1182. a string indicating the cause of the error.
  1183.  
  1184. 
  1185. File: python-lib.info,  Node: UNIX ONLY,  Next: AMOEBA ONLY,  Prev: MOST OPERATING SYSTEMS,  Up: Top
  1186.  
  1187. UNIX ONLY
  1188. *********
  1189.  
  1190. * Menu:
  1191.  
  1192. * pwd::                         Built-in Module `pwd'
  1193. * grp::                         Built-in Module `grp'
  1194. * socket::                      Built-in Module `socket'
  1195. * select::                      Built-in module `select'
  1196. * dbm::                         Built-in Module `dbm'
  1197. * thread::                      Built-in Module `thread'
  1198.  
  1199. 
  1200. File: python-lib.info,  Node: pwd,  Next: grp,  Up: UNIX ONLY
  1201.  
  1202. Built-in Module `pwd'
  1203. =====================
  1204.  
  1205. This module provides access to the UNIX password database.  It is
  1206. available on all UNIX versions.
  1207.  
  1208. Password database entries are reported as 7-tuples containing the
  1209. following items from the password database (see `<pwd.h>'), in order:
  1210. `pw_name', `pw_passwd', `pw_uid', `pw_gid', `pw_gecos', `pw_dir',
  1211. `pw_shell'.  The uid and gid items are integers, all others are
  1212. strings.  An exception is raised if the entry asked for cannot be
  1213. found.
  1214.  
  1215. It defines the following items:
  1216.  
  1217.  -- function of module pwd: getpwuid (UID)
  1218.      Return the password database entry for the given numeric user ID.
  1219.  
  1220.  -- function of module pwd: getpwnam (NAME)
  1221.      Return the password database entry for the given user name.
  1222.  
  1223.  -- function of module pwd: getpwall ()
  1224.      Return a list of all available password database entries, in
  1225.      arbitrary order.
  1226.  
  1227. 
  1228. File: python-lib.info,  Node: grp,  Next: socket,  Prev: pwd,  Up: UNIX ONLY
  1229.  
  1230. Built-in Module `grp'
  1231. =====================
  1232.  
  1233. This module provides access to the UNIX group database.  It is
  1234. available on all UNIX versions.
  1235.  
  1236. Group database entries are reported as 4-tuples containing the
  1237. following items from the group database (see `<grp.h>'), in order:
  1238. `gr_name', `gr_passwd', `gr_gid', `gr_mem'.  The gid is an integer,
  1239. name and password are strings, and the member list is a list of
  1240. strings.  (Note that most users are not explicitly listed as members
  1241. of the group(s) they are in.) An exception is raised if the entry
  1242. asked for cannot be found.
  1243.  
  1244. It defines the following items:
  1245.  
  1246.  -- function of module grp: getgrgid (GID)
  1247.      Return the group database entry for the given numeric group ID.
  1248.  
  1249.  -- function of module grp: getgrnam (NAME)
  1250.      Return the group database entry for the given group name.
  1251.  
  1252.  -- function of module grp: getgrall ()
  1253.      Return a list of all available group entries entries, in
  1254.      arbitrary order.
  1255.  
  1256.